package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc  电话录音表
 * @author yangzj
 * @datetime 2014年10月14日,下午7:29:22
 */
@Entity
@Table(name = "medical_call_recording")
public class MedicalCallRecording implements Serializable, JSONAware{
	
	private static final long serialVersionUID = -2301401564273180377L;
	
	private String id;					// 电话录音表id
	private String callerNum;			// 主叫号码
	private String calledNum;			// 被叫号码
	private String seat;				// 坐席
	private Date callTime;				// 呼叫时间
	private Integer talkTime;			// 通话时长
	private String callProvince;		// 呼叫省
	private String callCity;			// 呼叫市
	private String centerId;			// 中心ID
	private String groupId;				// 组ID
	private String userId;				// 用户ID
	private String isOpen;				// 是否公开  0不公开 1公开
	private String recordingFile;		// 录音文件
	private String hospitalId;			// 医院企业id
	
	private Date startTime;				// 开始时间
	private Date endTime;				// 截至时间
	private String ids;					// 多个id
	
	private Integer talkTimeLess;
	private Integer talkTimeMore;
	private String seatName;			// 坐席姓名
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name = "caller_num", length = 20)
	public String getCallerNum() {
		return callerNum;
	}
	
	public void setCallerNum(String callerNum) {
		this.callerNum = callerNum;
	}
	
	@Column(name = "called_num", length = 20)
	public String getCalledNum() {
		return calledNum;
	}
	
	public void setCalledNum(String calledNum) {
		this.calledNum = calledNum;
	}
	
	@Column(name = "seat", length = 32)
	public String getSeat() {
		return seat;
	}
	
	public void setSeat(String seat) {
		this.seat = seat;
	}
	
	@Column(name = "call_time")
	public Date getCallTime() {
		return callTime;
	}
	
	public void setCallTime(Date callTime) {
		this.callTime = callTime;
	}
	
	@Column(name = "talk_time", length = 11)
	public Integer getTalkTime() {
		return talkTime;
	}
	
	public void setTalkTime(Integer talkTime) {
		this.talkTime = talkTime;
	}
	
	@Column(name = "call_province", length = 32)
	public String getCallProvince() {
		return callProvince;
	}
	
	public void setCallProvince(String callProvince) {
		this.callProvince = callProvince;
	}
	
	@Column(name = "call_city", length = 32)
	public String getCallCity() {
		return callCity;
	}
	
	public void setCallCity(String callCity) {
		this.callCity = callCity;
	}
	
	@Column(name = "center_id", length = 32)
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	@Column(name = "is_open", length = 5)
	public String getIsOpen() {
		return isOpen;
	}

	public void setIsOpen(String isOpen) {
		this.isOpen = isOpen;
	}
	
	@Column(name = "recording_file", length = 255)
	public String getRecordingFile() {
		return recordingFile;
	}

	public void setRecordingFile(String recordingFile) {
		this.recordingFile = recordingFile;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Transient
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Transient
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Transient
	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}
	
	@Transient
	public Integer getTalkTimeLess() {
		return talkTimeLess;
	}

	public void setTalkTimeLess(Integer talkTimeLess) {
		this.talkTimeLess = talkTimeLess;
	}

	@Transient
	public Integer getTalkTimeMore() {
		return talkTimeMore;
	}

	public void setTalkTimeMore(Integer talkTimeMore) {
		this.talkTimeMore = talkTimeMore;
	}
	
	@Transient
	public String getSeatName() {
		return seatName;
	}

	public void setSeatName(String seatName) {
		this.seatName = seatName;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj =new JSONObject();
		obj.put("id", id);
		obj.put("callerNum", callerNum);
		obj.put("calledNum", calledNum);
		obj.put("seat", seat);
		obj.put("recordingFile", recordingFile);
		if(this.callTime != null){
			obj.put("callTime", DateFormatUtils.format(this.callTime,"yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("talkTime", talkTime);
		obj.put("isOpen", isOpen);
		if("0".equals(isOpen)){
			obj.put("isOpenText", "不公开");
		}else if("1".equals(isOpen)){
			obj.put("isOpenText", "公开");
		}
		obj.put("callProvince", callProvince);
		obj.put("callCity", callCity);
		obj.put("seatName", seatName);
		return obj.toString();
	}
}
